package main

import (
	"flag"
	"io/fs"
	"io/ioutil"
	"log"
	"math/rand"
	"os"
	"server/base"
	"server/biz"
	"time"
)

var args struct {
	File string
}

func init() {
	log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile)
	log.SetOutput(os.Stdout)

	flag.StringVar(&args.File, "f", "ps4.xlsx", "excel文件路径")
	rand.Seed(time.Now().Unix())
}

func main() {
	flag.Parse()

	log.Println("file:", args.File)
	rows := biz.ReadExcel(args.File)
	s := base.JsonString(rows)
	s = "var gametable=" + s + ";"
	err := ioutil.WriteFile("gametable.js", []byte(s), fs.ModePerm)
	base.Raise(err)
}
